import redis
class Mredis():
    def __init__(self):
        self.pool = redis.ConnectionPool(host='localhost', port=6379, db=0, decode_responses=True)
        self.r = redis.Redis(connection_pool=self.pool)
    #存列表
    def rpush(self,key,value):
        return self.r.rpush(key,value)

    def lpop(self,key,value):
        return self.r.lpop(key)
    #取列表
    def lrange(self,key,start,end):
        return self.r.lrange(key,start,end)
    #列表长度
    def llen(self,key):
        return self.r.llen(key)

    def rpoplpush(self,key1,key2):
        return self.r.rpoplpush(key1,key2)
    #删除元素
    def lrem(self,key,value):
        return self.r.lrem(key,value)
    #删除
    def ltrim(self,key,start,stop):
        return self.r.ltrim(key,start,stop)
r = Mredis()